home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: main.c,v $
- * $Revision: 1.2 $
- * $Date: 1996/05/04 23:51:46 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "trace_funcs.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "disk.h"
- #include "volume.h"
- #include "queues.h"
- #include "queue_consist.h"
- #include "disk_funcs.h"
- #include "diskproc_globals.h"
- #include "diskproc_intfuncs.h"
- #include "diskproc_extfuncs.h"
-
- main (
- int argc,
- char **argv
- )
- {
-
-
- /*
- * check to see that we have the right number of arguments
- */
- # define NARGS 10
-
- if (argc != NARGS ) {
- fprintf(stderr, "%d args on exec: expected %d\n", argc, NARGS);
-
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * set the trace levels
- */
- initializeTrace();
-
- /*
- * ARGV[1] get the value of trace
- */
- TraceFlags = (int) strtol(argv[1], NULL, 16);
- TRACE(TR_DISKRW, TR_LEVEL_1);
-
- initErrorCodes();
-
- TRACE(TR_DISKRW, TR_LEVEL_1);
- catchSignals();
-
- TRACE(TR_DISKRW, TR_LEVEL_1);
- /*
- * ARGV[2] get the shared memory id
- */
- ShmId = (int) strtol(argv[2], NULL, 16);
- TRACE(TR_DISKRW, TR_LEVEL_1);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("shared memory id:%x", ShmId));
-
-
- /*
- * attach the shared memory segment
- */
- if ((ShmAddress = shmat(ShmId, 0, 0)) == (char *) -1) {
-
- SM_ERROR(TYPE_FATAL, errno);
- }
- TRPRINT(TR_INIT, TR_LEVEL_1, ("shared memory attached at:%x", ShmAddress));
-
- /*
- * get shared memory information
- */
- if (shmctl(ShmId, IPC_STAT, &Shmstruct) < 0) {
-
- SM_ERROR(TYPE_FATAL, errno);
- }
- #if defined(_AIX) || defined(hpux) || defined(sparc) || defined(linux)
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("shared memory size:%d",
- Shmstruct.shm_segsz));
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("shared memory ref count:%d",
- Shmstruct.shm_nattch));
- #else
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("shared memory size:%d",
- Shmstruct.sm_size));
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("shared memory ref count:%d",
- Shmstruct.sm_count));
- #endif
-
- /*
- * ARGV[3] get the number of the communications socket
- */
- Socket = (int) strtol(argv[3], NULL, 16);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("socket id:%d", Socket));
-
-
- /*
- * ARGV[4] get the volume name
- */
- DiskName = argv[4];
-
- /* ARGV[5]
- * Get the id for the semaphore list that
- * we'll use to sync with the server when
- * manipulating disk queues.
- */
- SemId = (int) strtol(argv[5], NULL, 16);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("sem id:%d", SemId));
-
- /* ARGV[6]
- * Get the semaphore number within the semaphore list.
- */
- SemNum = (int) strtol(argv[6], NULL, 16);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("Disk #:%d", SemNum));
-
- {
- ShmOffset offset;
-
- /*
- * ARGV[7] Find our queue pair.
- */
- offset = (ShmOffset) strtol(argv[7], NULL, 16);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("argv[7] is %s",argv[8]));
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("queue offset #:%d", offset));
- DiskQueue = ShmOffsetToAddress(offset, QUEUEPAIR);
-
- /*
- * ARGV[9] Find the semaphore for kicking the server.
- */
- offset = (ShmOffset) strtol(argv[8], NULL, 16);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("argv[8] is %s",argv[9]));
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("Replies offset #:%d", offset));
- Replies = ShmOffsetToAddress(offset, MUTEX);
-
- /*
- * ARGV[9] Get NumMsgBufs so that the queuing macros work.
- * (NumMsgBufs is what's used for QUEUE_SIZE)
- */
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("argv[9] is %s",argv[10]));
- NumMsgBufs = (int) strtol(argv[9], NULL, 16);
- TRPRINT(TR_DISKRW, TR_LEVEL_1, ("NumMsgBufs :%d", NumMsgBufs));
-
- /*
- * That's all folks!
- * The elements stashed in the queues are offsets from ShmAddress,
- * so we don't need to know where the msg buffers start
- * and end or where the disk queues start & end.
- */
- }
-
- /*
- * get our parent's pid - we'll need it later to
- * detect server death
- */
- if((Parent = getppid())<0) {
- SM_ERROR(TYPE_FATAL, errno);
- }
- TRPRINT(TR_INIT, TR_LEVEL_1, ("Parent pid is %d", Parent));
-
- process_identity.me = DISK_PROC;
- process_identity.other = (1-process_identity.me);
-
- /*
- * start the read loop
- */
- readDiskMessage();
- }
-